<html>
<head>
    <meta charset="UTF-8">
    <title>服务器信息列表</title>
    <link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
    <link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
    <link href="../../static/css/esaas-easyui-add.css" rel="stylesheet" type="text/css"/>
    <script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
    <script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
    <script src="../../ffres/dict/all.js" type="text/javascript"></script>
    <link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
    <a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">
    var localPath;

    $(function () {
        addTitle("服务器选择");
        getLocalPath();

    })
    function selectReturn() {
        var row = $('#dg').datagrid('getSelected');
        var subsCode = $.getUrlParam("subsCode");
        var bpmId = $.getUrlParam("bpmId");
        if (row) {
            if (bpmId!=null){
                let jsonData = {
                    ecsName:row.ecsName,
                    ecsIp:row.ecsIp,
                    ecsPurpose:row.ecsPurpose,
                    ecsRegion:row.ecsRegion,
                    ecsOs:row.ecsOs,
                    ecsVcpu:row.ecsVcpu,
                    ecsMemory:row.ecsMemory,
                    ecsDisk:row.ecsDisk,
                    ecsLoginMethod:row.ecsLoginMethod,
                    ecsLoginUser:row.ecsLoginUser,
                    ecsState:row.ecsState,
                    ecsDesc:row.ecsDesc,
                    ecsLoginPwd:row.ecsLoginPwd,
                    localPath:localPath
                }
                window.parent.onChooseOrgName(jsonData)
                window.parent.JLEUtil.closewin();
            }else {
                let jsonData={
                    subsCode:subsCode,
                    ecsId:row.ecsId
                }
                $.restfulPostJson('../../api/sys/ecs/info', jsonData, function(data) {
                    window.parent.reloadList();
                });
            }

        } else {
            $.messager.alert('提示', '请选择一条记录！', 'info');
        }
    }

    function closeForm() {
        window.parent.JLEUtil.closewin();
    }

    function getLocalPath(){
       $.restfulGet('../../api/s/param/info/localPath',null,function (data){
          localPath = data.rows.paramValue;
       })
    }


    function reloadList(){
        $('#dg').datagrid('reload');
        JLEUtil.closewin();
    };

</script>

<body class="easyui-layout">
<div data-options="region:'north'"  style="height: 74px;">
    <div data-options="region:'north'" style="height: 28px;" >
        <div class="esaas-info-title2" style="background-color: #205081;" >
            <div style="padding: 2px;"></div>
            &nbsp;&nbsp;选择服务器
            <a class="easyui-menubutton" style="position:absolute;right: 5px;top: 1px;width:22px;height: 22px;background-image: url('../../static/easyui/themes/icons/cancel6.png')"
               onclick="closeForm()"
            >
            </a>
        </div>
    </div>
    <form id="searchForm">
        <table>
            <tr>
                <td class="searchTd">&nbsp;服务器用途：</td>
                <td><select class="easyui-combobox"
                            id="ecsPurpose" name="ecsPurpose"
                            style="width: 100%; height: 25px;"
                            data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:ECS_PURPOSE" /></td>
                <td class="searchTd">&nbsp;服务器名称：</td>
                <td><input name="ecsName" id="ecsName"/></td>
                <td class="searchTd">&nbsp;服务器IP：</td>
                <td><input name="ecsIp" id="ecsIp"/></td>
                <td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.queryForm('searchForm','dg','../../api/ecs/base/infos');">查找</a></td>
                <td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
            </tr>
        </table>
    </form>
</div>
<div data-options="region:'center',split:false">
    <table id="dg" class="easyui-datagrid" title="" style="width:100%;height:94%"
           data-options="singleSelect:true,collapsible:true,url:'../../api/ecs/base/infos',method:'post'"
           toolbar="#tb"
           title="Load Data"
           rownumbers="true" pagination="true" pageSize="20">
        <thead>
        <tr>
            <th data-options="field:'ecsName',resizable:true" >服务器名称</th>
            <th data-options="field:'ecsIp',resizable:true" align="center">服务器IP</th>
            <th data-options="field:'ecsPurpose',resizable:true" formatter="formatter_ECS_PURPOSE">服务器用途</th>
            <th data-options="field:'ecsRegion',resizable:true" formatter="formatter_ECS_REGION">所在位置</th>
            <th data-options="field:'ecsOs',resizable:true" formatter="formatter_ECS_OS">操作系统</th>
            <th data-options="field:'ecsVcpu',resizable:true" align="center">CPU(核)</th>
            <th data-options="field:'ecsMemory',resizable:true" align="center">内存(G)</th>
            <th data-options="field:'ecsDisk',resizable:true" align="center">磁盘(G)</th>
            <th data-options="field:'ecsLoginMethod',resizable:true" formatter="formatter_ECS_LOGIN_METHOD">登录方式</th>
            <th data-options="field:'ecsLoginUser',resizable:true" >登录用户</th>
            <th data-options="field:'ecsState',resizable:true" formatter="formatter_ECS_STATE">状态</th>
            <th data-options="field:'ecsDesc',resizable:true" width="20%">描述</th>
        </tr>
        </thead>
    </table>
</div>
<div data-options="region:'south',split:false" overflow="hidden" style="height: 105px">
    <div style="text-align: center; padding: 30px 0px 30px;height: 40px;" >
        <a href="javascript:void(0)" class="easyui-linkbutton"
           onclick="selectReturn()">&nbsp;选择返回&nbsp;</a>
        <a href="javascript:void(0)" class="easyui-linkbutton"
           onclick="closeForm()">&nbsp;关&nbsp;闭&nbsp;</a>
    </div>
</div>
</body>

</html>